<%@ page language="java" import="java.util.*,java.sql.*,com.ts.util.connDB.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html"
	prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean"
	prefix="bean"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>admins</title>

<style type="text/css">
 @import url(admin/css/admin.css);
 </style>
<link href="admin/css/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/ajax.js"></script>
<script type="text/javascript" src="js/jigou.js"></script>
<script type="text/javascript" src="js/prototype-1.6.0.3.js"></script>
<style type="text/css">
<!--
.STYLE1 {color: #FFFFFF}
.STYLE5 {color: #009900}
-->
</style>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js/jquery.page.js"></script>
<script src="js/date.js" type="text/javascript"></script>
<script src="admin/js/designerMessage.js" type="text/javascript"></script>
<link rel="stylesheet" href="css/jquery.page.css" type="text/css"/>

</head>

<body style="width:95%;  " >
	<c:if test="${!empty message}">
			<script type="text/javascript">
  		var msg="${message}";
  		alert(msg);
  	</script>
			<c:remove var="message" />
		</c:if>
<div style="width:100%; h eight:100%; background:#f8ffff; margin:5px; margin-right:0; border:#CCCCCC solid 1px;">
  <div id="CollapsiblePanel1" class="CollapsiblePanel">
    <div class="CollapsiblePanelTab" tabindex="0">行业资讯管理</div>
    <div class="CollapsiblePanelContent">
      <table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#F8FFFF" id="datas">
      <tr>
       <td colspan="7">
       <form action="admin.do?method=findByWord" method="post">
	       <table width="100%">
			    <tr>
			    <td width="77%"  align="right">
			    <strong><a href="admin/addItem.jsp">添加项目</a></strong>
			    
			    </td>
			    <td width="15%" align="center">
			    
			      </td>
			      <td width="3%">
			     
			    </td>
			    </tr>
	    	</table>
    	</form>
       </td>
      </tr>
        <tr>
          <td height="23" width="230" colspan="2" align="center" valign="middle" bgcolor="#999999"><label></label> <span class="STYLE1">资讯标题</span></td>
          <td width="230" height="23" align="center" valign="middle" bgcolor="#999999" class="STYLE1">发布时间</td>
          <td width="230" height="23" align="center" valign="middle" bgcolor="#999999" class="STYLE1">操 作</td>
        </tr>
        <tr>
          <td width="29" height="12" align="center" valign="middle">&nbsp;</td>
          <td width="104" height="12" align="center" valign="middle">&nbsp;</td>
         <td width="104" height="12" align="center" valign="middle">&nbsp;</td>
        </tr>
     <%!  int pageSize = 8;//每页显示的记录数
     int pageCount = 0;//总页数
%>			
				<%
    ResultSet rs = null;
    Statement stmt = null;
    Connection con = null;

    try {
         con = ConnDB.getConn();
         stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);//可滚动查询数据的结果集
         rs =   stmt.executeQuery("select * from news  where type = '行业资讯'  order by phtime desc");
         rs.last(); //让游标到表中的最后一行
        int rowCount = rs.getRow(); //获取记录总数.
        //out.print("总记录数为"+rowCount);
        //总页数的计算公式
         pageCount = (rowCount % pageSize == 0) ? (rowCount / pageSize ) : (rowCount / pageSize +1);
        int showPage = 1;//当前页

    //取得用户所指定的页
     String goToPage = request.getParameter("showPage");
    if (goToPage == null){
         goToPage = "1";
     }
    
    //转换成整形
    try{
         showPage = Integer.parseInt(goToPage);
     }
    catch (NumberFormatException ex){
         showPage = 1;
     }
    
    //当前页小于等于第一页 则按第一页算 如果 当前页大于等于总页数则为最后页
    if(showPage <=1){
         showPage = 1;
     }
    else if(showPage >= pageCount){
         showPage =   pageCount;
     }
    
    //游标的位置 (当前页 - 1) * 页面大小 + 1
    int posion = (showPage -1 ) * pageSize + 1;
    //设置游标的位置 
     rs.absolute(posion);

%>
    
   <%
if(rowCount == 0){
%>
<h3><center><font color="red">对不起，还没有相关信息！</font></center></h3>
      
  
<%
}else{
   int i =0;
   //循环显示表中的数据 pageSize(每页所显示的记录)
   //rs.isAfterLast() 游标是否在最后一行之后 说明后面已经没记录
   while(i<pageSize && !rs.isAfterLast()){  
    
    %>
				
			<% 
			  if(i%2 == 0){
			  %>
			   <tr style="background: #FCFCF3">
			  
			  <%
			  }else{
			  %>
                <tr>
			  
			  <%
			  }
			%>	 
       
          <td width="29" height="25" align="center" valign="middle">&nbsp;</td>
          <td width="104" height="25" align="center" valign="middle">
          <%
									  String title = rs.getString("title");
                                     
									 %>
									 <%=title%>
          </td>
          <td width="104" height="25" align="center" valign="middle">
         <%=rs.getDate("phtime") %>
          </td>
          <td height="12" align="center" valign="middle"><!--  <a href=admin.do?method=lookJob&id=<%//=rs.getString("id")%> >查看</a>-->
                                    
                                        <a  href="admin.do?method=updateHangye&id=<%=rs.getString("id")%>"  >修改</a>
                                     

									
 &nbsp; <a href="javascript:void(0)" onClick="if(window.confirm('您确定要删除吗?')) this.href='admin.do?method=deleteHangye&id=<%=rs.getString("id")%>'"> 删除</a>&nbsp;</td>
        </tr>
       <%rs.next();i++;}}%>
      </table>
     <%
		 int cun = rowCount;
	 %>


<div  style="cursor: pointer;" align="center" >
			<form action="" name="customerForm" method="post">
				          <table  width="609px" style="margin-left:15px;" >
<tr>
			<td align="right" >
							共<%=cun%>条信息  当前第<%=showPage%>页  共有<%=pageCount%>页
                            
                            <%if(showPage == 1){%>     
                                                                                首页
                            <%}else{ %>
                            <a href="admin.do?method=managerHangye&showPage=1" style="color: blue;">首页</a>                           
                             <%} %>
                            
                            <%if(showPage > 1){%>
                                 <a href="admin.do?method=managerHangye&showPage=<%=showPage-1%>" style="color: blue;">上一页</a>
                             <%}else{%> 
                                                                                    上一页
                              <%} %>                          
                            
                          
                             <%if(showPage < pageCount){%>
                                <a href="admin.do?method=managerHangye&showPage=<%=showPage+1%>" style="color: blue;">下一页</a>
                             <%}else{%> 
                                                                                         下一页
                              <%} %> 
                          
                           <%if(showPage == pageCount){%>     
                                                                                尾页
                            <%}else{ %>
                            <a href="admin.do?method=managerHangye&showPage=<%=pageCount%>" style="color: blue;">尾页</a>                          
                             <%} %>
                                                      
                            
							转到
							<select name="select" id="page" onchange="subPage()" style="width:42px; height: 18px;line-height:18px;border:1px #ccc solid">
								<%
								  for(int k=1;k<=pageCount;k++){
								   if(k == showPage){
								  %>
								  <option value=<%=k%> selected>
												<%=k%>
								  </option>
								  <% 
								  }else{
								  %> 
								  <option value=<%=k%> >
												<%=k%>
								  </option>
								  <%
								  }
								  }
								%>
								
							</select>
				
	</td>
		</tr>
	</table>

	</form>	
			
		</div>



		
		
		
		<% 

}  catch (Exception e) {
  e.printStackTrace();
}finally{
 try{
     rs.close();
     stmt.close();
     con.close();
 }catch(Exception ee){
    ee.printStackTrace();
 }
}


%>
		
	  
	
    </div>
  </div>
</div>
<script type="text/javascript">
	
		function subPage(){
		   
		    var ss = customerForm.select.value;
		    
			document.forms.customerForm.action='admin.do?method=managerHangye&showPage=' + ss;
			
			document.forms.customerForm.submit();
		}
</script>
</body>
</html>

